<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>千园千变，万班万课</title>
    <meta name="description" content="这是一个 index 页面">
    <meta name="keywords" content="index">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <link rel="icon" type="image/png" href="assets/i/favicon.png">
    <link rel="apple-touch-icon-precomposed" href="assets/i/app-icon72x72@2x.png">
    <meta name="apple-mobile-web-app-title" content="Amaze UI"/>
    <link rel="stylesheet" href="assets/css/amazeui.min.css"/>
    <link rel="stylesheet" href="assets/css/admin.css">
    <link rel="stylesheet" href="assets/css/app.css">
</head>
<body>
<div class="tpl-portlet-components">
    <div class="portlet-title">
        <ol class="am-breadcrumb">
            <li><a href="#" class="am-icon-home">首页</a></li>
            <li><a href="#">表单</a></li>
            <li class="am-active">Amaze UI 表单</li>
        </ol>
    </div>
    <div class="tpl-block ">
        <div class="am-g tpl-amazeui-form">
            <div class="am-u-sm-12">
                <form class="am-form am-form-horizontal">
                    <div class="am-form-group">
                        <label for="type" class="am-u-sm-2 am-form-label">班级类型</label>
                        <div class="am-u-sm-10 line">
                            <select id="type" name="type" data-am-selected="" class="verification[MustSelect]" data-info="班级类型">
                                <option value="0">请选择类型</option>
                                <option value="1">大班</option>
                                <option value="2">中班</option>
                                <option value="3">小班</option>
                            </select>
                            <span class="tips"></span>
                        </div>
                    </div>
                    <div class="am-form-group">
                        <label for="weakest" class="am-u-sm-2 am-form-label">最弱项</label>
                        <div class="am-u-sm-10 line">
                            <select id="weakest" class="verification[MustSelect]" data-info="最弱项" name="weakest"  style="width: 200px">
                                <option value="0">请选择最弱项</option>
                                <option value="xz">下肢力量</option>
                                <option value="sz">上肢力量</option>
                                <option value="ph">平衡性</option>
                                <option value="rr">柔韧性</option>
                                <option value="lm">灵敏性</option>
                                <option value="xt">协调性</option>
                                <option value="jh">均衡课程</option>
                            </select>
                            <span class="tips"></span>
                        </div>
                    </div>
                    <div class="am-form-group">
                        <label for="class_name" class="am-u-sm-2 am-form-label">班级名称</label>
                        <div class="am-u-sm-10 line">
                            <input type="text" class="verification[required]" data-info="班级名称"
                                   id="class_name" name="class_name" style="width: 300px" placeholder="输入班级名称">
                            <span class="tips"></span>
                        </div>
                    </div>
                    <div class="am-form-group">
                        <div class="am-u-sm-9 am-u-sm-push-2"  style="margin-bottom: 100px;margin-top: 20px;">
                            <button type="button" class="am-btn am-btn-primary" id="submitBtn">确定</button>
                            <button type="button" class="am-btn am-btn-default btn_back">返回</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>

</div>
<script src="assets/js/jquery.min.js"></script>
<script src="assets/js/amazeui.min.js"></script>
<script src="assets/js/layer.js"></script>
<script src="assets/js/jquery.cookie.js"></script>
<script src="assets/js/md5.min.js"></script>
<script src="assets/js/verification.js"></script>
<script src="assets/js/request.js"></script>
<script src="assets/js/jquery.pagination.js"></script>
<script src="assets/js/jquery.serializejson.min.js"></script>
<script src="assets/js/jquery.params.js"></script>
<script src="assets/js/app.js"></script>
<script>
var id = $.query.get("id").toString() || "undefined";
function getInfo () {
  if (id!=='undefined') {
    $('#type').attr('disabled',true)

    AjaxRequest({
      url:'/school/class_info/',
      data: {school_class_id:id},
      succFun: function (res) {
        var data=res.data
        var dataForm={
          class_name:$.query.get("class_name"),
          weakest:$.query.get("weakest"),
          type:$.query.get("type"),
        }
        if(data.update_weakest =='1'){
         $('#weakest').attr('disabled',true)
       }
        $("form").initForm(dataForm);
        $('#weakest ,#type').trigger('changed');
      }
    })

  }
}
getInfo()
$('#submitBtn').click(function (e) {
  e.preventDefault()
  if (Verification()) {
    var formData = $('form').serializeJSON()
    var url='/school/class_add/'
    if(id!=='undefined'){
      formData.school_class_id = id
      url='/school/class_edit'
    }
    AjaxRequest({
      url,
      data: formData,
      succFun: function (res) {
        layer.msg(res.message, {icon: 1, time: 1000}, function () {
          window.location.href='class_list.html'
        })
      }
    })
  }
})
</script>
</body>
</html>